<?php
session_start();
require_once('Http_do.php');
header("Content-Type:text/html; charset=utf-8");
preg_match("/channel=(\d+)/", $_SERVER['HTTP_REFERER'], $matches);
if(empty($matches))
{
	$channel=0;	
}
else
{
	$channel=$matches[1];	
}
$name = $_POST['name'];
$_SESSION['mobile']=$mobile = $_POST['mobile'];
if($name && $mobile){
	$interface_return=Http_do::doPost($interface_url,array('type'=>1,'mobile'=>$mobile));
	if($interface_return){
		header('Location:index.php?s=2');
		exit();
	}
	$province = $_POST['province'];
	$city = $_POST['city'];
	$ip = $_SERVER['REMOTE_ADDR'];
	$cartype = $_POST['cartype'];
	$logtime = date('Y-m-d H:i:s');
	$interface_return=Http_do::doPost($interface_url,
	array('type'=>2,
				'name'=>$name,
				'mobile'=>$mobile,
				'province'=>$province,
				'city'=>$city,
				'ip'=>$ip,
				'cartype'=>$cartype,
				'logtime'=>$logtime,
				'channel'=>$channel
				));
	if ($interface_return) {
		header('Location:index.php?s=1');
	} else {
		header('Location:index.php?s=0');
	}
} else {
	echo "<script>alert('手机和用户名不能为空！');</script>";
	header('Location:index.php');
}
?>